<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>酒店后台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet"
          th:href="@{/adminlte/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/Ionicons/css/ionicons.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/adminlte/dist/css/AdminLTE.min.css}">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" th:href="@{/adminlte/dist/css/skins/_all-skins.min.css}">
    <!-- Morris chart -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/morris.js/morris.css}">
    <!-- jvectormap -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/jvectormap/jquery-jvectormap.css}">
    <!-- Date Picker -->
    <link rel="stylesheet"
          th:href="@{/adminlte/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css}">
    <!-- Daterange picker -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/bootstrap-daterangepicker/daterangepicker.css}">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" th:href="@{/adminlte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css}">

</head>
<body class="hold-transition skin-blue sidebar-mini" onload="startClock()" onunload="stopClock()">
<div class="wrapper">

    <div th:replace="/common/backCommon::header"></div>
    <!-- Left side column. contains the logo and sidebar -->
    <div th:replace="/common/backCommon::menu"></div>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                酒店数据
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 主页</a></li>
               <li><a th:href="@{/city/getAll}"><i class="fa fa-circle-o"></i>城市数据</a></li>
                <li class="active">房间数据</li>>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <style>
                label{
                    font-size:16px ;
                }
            </style>
            <!--   这里写具体功能部分   -->
            <div class="box">
                <div class="box-header">
                    <h3 class="box-title">修改房间数据：</h3>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <form th:action="@{/room/edit}" method="post" th:object="${room}">
                        <div class="col-xs-3" style="margin-left: 35%">
                            <label>酒店编号</label>
                            <input type="text" class="form-control"  name="hotelId" th:value="*{hotelId}" readonly>
                            <label>房间编号</label>
                            <input type="text" class="form-control" name="roomId" th:value="*{roomId}" readonly>
                            <label>房间类型</label>
                            <input type="text" class="form-control" name="roomType" th:value="*{roomType}">
                            <label>房间价格</label>
                            <input type="text" class="form-control" name="roomPrize" th:value="*{roomPrize}">
                            <label>房间状态</label>
                            <!--    <input type="text" class="form-control" name="roomPrize">-->
                            <select name="roomSign" id="roomSign" class="form-control">
                                <option value="1">未满</option>
                                <option value="0">已满</option>
                            </select>
                            <label id="imageText">房间图片</label>
                            <br/>
                            <span th:each="roomImage:${roomImages}" style="width: 100px">
                                <img th:src="@{'/img/'+${roomImage.imageName}}" style="width: 25%;height:80px;margin-top:1%">
                                <input type="checkbox" name="imageId" th:value="${roomImage.imageId}">
                            </span>
                            </br>
                            <button type="button"  id="deleteImage" style="margin-top: 1%;">删除图片</button>
                            <br/>
                            <button type="submit" class="btn btn-info" style="margin-left: 20%;margin-top: 2%" >提交</button>
                            <button type="button" onclick="javascript :history.back(-1);" class="btn btn-info" style="margin-left: 20%;margin-top: 2%" >取消</button>
                        </div>
                    </form>
                    <form th:action="@{/room/addImage}" method="post" enctype="multipart/form-data">
                        <div class="col-xs-3" >
                            <label>添加图片</label>
                            <input type="file" name="file" multiple="multiple" id="changePhoto" style="margin-top: 2%">
                            <input type="text" name="roomId" th:value="${room.roomId}" hidden>
                            <div id="hotelImage"></div>
                            <button type="submit">添加</button>
                        </div>
                    </form>
                </div>
                <!-- /.box-body -->
            </div>

        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <div th:replace="/common/backCommon::footer"></div>


</div>
<!-- ./wrapper -->
<!-- jQuery 3 -->
<script th:src="@{/adminlte/bower_components/jquery/dist/jquery.min.js}"></script>
<!-- jQuery UI 1.11.4 -->
<script src="@{/adminlte/bower_components/jquery-ui/jquery-ui.min.js}"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
    $.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.7 -->
<script th:src="@{/adminlte/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
<!-- Morris.js charts -->
<script th:src="@{/adminlte/bower_components/raphael/raphael.min.js}"></script>
<script th:src="@{/adminlte/bower_components/morris.js/morris.min.js}"></script>
<!-- Sparkline -->
<script th:src="@{/adminlte/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js}"></script>
<!-- jvectormap -->
<script th:src="@{/adminlte/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js}"></script>
<script th:src="@{/adminlte/plugins/jvectormap/jquery-jvectormap-world-mill-en.js}"></script>
<!-- jQuery Knob Chart -->
<script th:src="@{/adminlte/bower_components/jquery-knob/dist/jquery.knob.min.js}"></script>
<!-- daterangepicker -->
<script th:src="@{/adminlte/bower_components/moment/min/moment.min.js}"></script>
<script th:src="@{/adminlte/bower_components/bootstrap-daterangepicker/daterangepicker.js}"></script>
<!-- datepicker -->
<script th:src="@{/adminlte/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js}"></script>
<!-- Bootstrap WYSIHTML5 -->
<script th:src="@{/adminlte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js}"></script>
<!-- Slimscroll -->
<script th:src="@{/adminlte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
<!-- FastClick -->
<script th:src="@{/adminlte/bower_components/fastclick/lib/fastclick.js}"></script>
<!-- AdminLTE App -->
<script th:src="@{/adminlte/dist/js/adminlte.min.js}"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script th:src="@{/adminlte/dist/js/pages/dashboard.js}"></script>
<!-- AdminLTE for demo purposes -->
<script th:src="@{/adminlte/dist/js/demo.js}"></script>
<!-- DataTables -->
<script th:src="@{/adminlte/bower_components/datatables.net/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/adminlte/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js}"></script>
<script>
    $(function () {
        $('#example1').DataTable({
            language: {
                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 项结果",
                "sZeroRecords": "没有匹配结果",
                "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                "sInfoPostFix": "",
                "sSearch": "搜索:",
                "sUrl": "",
                "sEmptyTable": "表中数据为空",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                },
                "oAria": {
                    "sSortAscending": ": 以升序排列此列",
                    "sSortDescending": ": 以降序排列此列"
                }
            }
        });
    })
    $(function () {
        $(".treeview-menu li a").each(function () {
            var url_regex=new RegExp("^.*酒店{1,}.*$");
            if(url_regex.test($(this).text())){
                $(this).parent(".treeview-menu li").addClass("active");
                $(this).parents(".treeview").addClass("active");
            }else {
                $(this).parent(".treeview-menu li").removeClass("active");
            }
        });
    });
    $("#deleteImage").click(function () {
        var checkId=$("input[name='imageId']:checked");
        var imageId=new Array();
        for (var i=0;i<checkId.length;i++){
            imageId[i]=checkId[i].value;
        }
        $.ajax({
            url : "/room/deleteImage",
            type : "POST",
            data : {
                imageId:imageId
            },
            traditional:true,
            //请求成功
            success : function(data) {
                if (data=true) {
                    $("input[name='imageId']:checked").parent().empty();
                    alert("删除成功")
                }
                console.log(data);
            }
        })
    })
    $(function () {
        $("#changePhoto").change(function () {
            $("#hotelImage").empty();
            var photo = this.files;
            for (var i = 0; i < photo.length; i++) {
                reads(photo[i]);
            }
        });
    });
    function reads(filename){
        var reader=new FileReader();
        reader.readAsDataURL(filename);
        reader.onload=function () {
            $("#hotelImage").attr("src",reader.result);
            var img="<img src="+reader.result+" "+"style=width:20%;height:63px;margin-left:1%;margin-top:2%"+">";
            $("#hotelImage").append(img);
        }
    }
</script>
<script th:src="@{/js/timer.js}"></script>
</body>
</html>
